<%@ page language="java" contentType="text/html; utf-8"
    pageEncoding="utf-8"%>
      <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>用户添加</title>
	

<meta name="renderer" content="webkit">

<script src="${pageContext.request.contextPath}/static/jquery/jquery-1.8.3.min.js" type="text/javascript"></script>
<link href="${pageContext.request.contextPath}/static/bootstrap/2.3.1/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<script src="${pageContext.request.contextPath}/static/bootstrap/2.3.1/js/bootstrap.min.js" type="text/javascript"></script>
<!--[if lte IE 6]>
<link href="static/bootstrap/bsie/css/bootstrap-ie6.min.css" type="text/css" rel="stylesheet" />
<script src="static/bootstrap/bsie/js/bootstrap-ie.min.js" type="text/javascript"></script>
<![endif]-->
<link href="${pageContext.request.contextPath}/static/jquery-select2/3.4/select2.min.css" rel="stylesheet" />
<script src="${pageContext.request.contextPath}/static/jquery-select2/3.4/select2.min.js" type="text/javascript"></script>
<link href="${pageContext.request.contextPath}/static/jquery-validation/1.11.0/jquery.validate.min.css" type="text/css" rel="stylesheet" />
<script src="${pageContext.request.contextPath}/static/jquery-validation/1.11.0/jquery.validate.min.js" type="text/javascript"></script>
<link href="${pageContext.request.contextPath}/static/jquery-jbox/2.3/Skins/Bootstrap/jbox.min.css" rel="stylesheet" />
<script src="${pageContext.request.contextPath}/static/jquery-jbox/2.3/jquery.jBox-2.3.min.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/static/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<link href="${pageContext.request.contextPath}/static/common/common.css" type="text/css" rel="stylesheet" />
<script src="${pageContext.request.contextPath}/static/common/common.js" type="text/javascript"></script>
<!-- <script type="text/javascript">var ctx = '', ctxStatic='/static';</script> -->
	<script type="text/javascript">
		$(function() {
			$("#no").focus();
			$("#inputForm").validate({
				/* rules: {
					loginName: {remote: "/sys/user/checkLoginName?oldLoginName=" + encodeURIComponent('')}
				}, */
				messages: {
					no: {remote: "用户登录名已存在"},
					confirmNewPassword: {equalTo: "输入与上面相同的密码"}
				},
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		//异步检验账号是否存在
		function doVerify(){
            //获取界面的账号
            var account =  $("#no").val();
            /* alert(account) */
            //获取账号后的提示信息文本
           /*  var accountText = document.getElementById("accountText"); */
            //如果账号输入不为空，执行该方法
            if(account !=""){
                $.ajax({
                    url:"${pageContext.request.contextPath}/sys/user.do?method=CheckIdExist",//后台查询验证的方法
                    data:{"Id": account},//携带的参数
                    type: "post",
                    success: function(msg){
                        //根据后台返回前台的msg给提示信息加HTML
                        if("true" !=msg){
                        	display.innerHTML = "<font color='#EA5200'>账号:"+account+"已被注册</font>"
                        	}
                        else{
                        	 // 账号不存在
                            display.innerHTML = "<font color='#61daa5'>"+account+"可以使用！</font>"
                        }
                        }
                      
 
                    /* success: function(data){
                    	 var result = jQuery.parseJSON(data);
                         $('#display b').text(result.res);
                    } */
                });
            }
        }

		
		
		
		
		
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${pageContext.request.contextPath}/sys/user.do?method=findUserByPage&tgId=${tgId}&pageNum=1">用户列表</a></li>
		<li class="active">
			<a href="userAdd.html">用户添加
			</a>
		</li>
	</ul><br/>
	<form id="inputForm" class="form-horizontal" action="${pageContext.request.contextPath}/sys/user.do?method=addUser" method="post">
		
				<input type = "hidden" name = "pageNum" value = "1">
				<input type = "hidden" name = "tgId" value = "${tgId}">
		<div class="control-group">
			<label class="control-label">工号:</label>
			<div class="controls">
				<input id="no" name="userid" class="required" type="text" value="" maxlength="50" onchange="doVerify()"/>
				<span class="help-inline"><span style="color:red"> *</span><b><span id="display"></span></b></span>
					
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">姓名:</label>
			<div class="controls">
				<input id="name" name="username" class="required" type="text" value="" maxlength="50"/>
				<span class="help-inline"><span style="color:red">*</span> </span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">密码:</label>
			<div class="controls">
				<input id="newPassword" name="newPassword" type="password" value="" maxlength="50" minlength="3" class="required"/>
				<span class="help-inline"><span style="color:red">*</span> </span>
				
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">确认密码:</label>
			<div class="controls">
				<input id="confirmNewPassword" name="password" type="password" value="" maxlength="50" minlength="3" equalTo="#newPassword"/>
				<span class="help-inline"><span style="color:red">*</span> </span>
			</div>
		</div>
		
		
		
		<div class="control-group">
			<label class="control-label">用户角色:</label>
			<div class="controls">
			    <c:forEach items="${roleList}" var="role">
			    <label for="roleIdList1">${role.roleName }</label></span>
				<span><input id="roleIdList1" name="roleIdList" class="required" type="checkbox" value="${role.roleId }"/>
				
				</c:forEach>
			</div>
		</div> 
		<div class="control-group">
			<label class="control-label">备注:</label>
			<div class="controls">
				<textarea id="remarks" name="remarks" maxlength="200" class="input-xlarge" rows="3"></textarea>
			</div>
		</div>
		<label class="control-label">所在区域:</label>
			<div class="controls">
			<select name="areacode" class="input w50"> 
           <c:forEach items="${requestScope.area}" var="area">
        		<option value="${area.areaCode}">${area.areaName}</option> 
        	</c:forEach>
        	</select>
			</div>
		<div class="form-actions">
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form>




<%-- 
		<form action="${pageContext.request.contextPath}/sys/user.do?method=addUser" method="post">
				账号：<input type = "text" name = "userid"><br>
				密码：<input type = "text" name = "password"><br>
				姓名：<input type = "text" name = "username"><br>
				<input type = "hidden" name = "pageNum" value = "1">
				<input type = "hidden" name = "tgId" value = "${tgId}">
				<input type ="submit" value="添加">
			
		</form>
		${msg } --%>
</body>
</html>